<template>
	<view class="page_box">
		<u-navbar :is-back="true" title="修改资料" v-if="1" :border-bottom="fasle"></u-navbar>

		<view class="content_box padding">
			<scroll-view scroll-y="true" style="height: 80vh;">
				<view class="padding-top padding-bottom-sm flex flex-direction solid-bottom">
					<text class="f28 text-bold text">姓名</text>
					<input
						type="text"
						value=""
						v-model="data.real_name"
						class="margin-top"
						placeholder="请输入姓名"
						placeholder-class="ddd"
					/>
				</view>
				<view class="padding-top padding-bottom-sm flex flex-direction solid-bottom">
					<text class="f28 text-bold text">性别</text>
					<view class="margin-top flex">
						<view class="flex" @click="gender(1)">
							<image
								src="../../static/dui22.png"
								mode="aspectFill"
								class="w30 h30 animation-scale-up"
								v-if="c == 1"
							></image>
							<image src="../../static/dui222.png" mode="aspectFill" class="w30 h30 " v-else></image>
							<text class="ml13">男</text>
						</view>
						<view class="flex ml60" @click="gender(2)">
							<image
								src="../../static/dui222.png"
								mode="aspectFill"
								class="w30 h30 "
								v-if="c == 1"
							></image>
							<image
								src="../../static/dui22.png"
								mode="aspectFill"
								class="w30 h30 animation-scale-up"
								v-else
							></image>
							<text class="ml13">女</text>
						</view>
					</view>
				</view>
				<view class="padding-top padding-bottom-sm flex flex-direction solid-bottom">
					<text class="f28 text-bold text">联系电话</text>
					<input
						type="text"
						value=""
						v-model="data.phone"
						class="margin-top"
						placeholder="请输入联系电话"
						placeholder-class="ddd"
					/>
				</view>
				<view class="padding-top padding-bottom-sm flex flex-direction solid-bottom">
					<text class="f28 text-bold text">公司名称</text>
					<input
						type="text"
						value=""
						v-model="data.company_name"
						class="margin-top"
						placeholder="请输入公司名称"
						placeholder-class="ddd"
					/>
				</view>
				<view class="padding-top padding-bottom-sm flex flex-direction solid-bottom">
					<text class="f28 text-bold text">所属行业</text>
					<input
						type="text"
						value=""
						v-model="data.industry_type"
						class="margin-top"
						placeholder="请输入所属行业"
						placeholder-class="ddd"
					/>
				</view>
				<view class="padding-top padding-bottom-sm flex flex-direction solid-bottom">
					<text class="f28 text-bold text">职位</text>
					<input
						type="text"
						value=""
						v-model="data.job_name"
						class="margin-top"
						placeholder="请输入职位"
						placeholder-class="ddd"
					/>
				</view>
				<view class="padding-top padding-bottom-sm flex flex-direction ">
					<text class="f28 text-bold text">企业/产品介绍</text>
					<view class="padding margin-top" style="background: #F7F7F7;">
						<textarea
							value=""
							v-model="data.product_description"
							placeholder="请输入产品介绍"
							placeholder-class="fff"
						/>
					</view>
				</view>
				<view class="padding-top padding-bottom-sm flex flex-direction ">
					<text class="f28 text-bold text">主营业务</text>
					<view class="padding margin-top" style="background: #F7F7F7;">
						<textarea
							value=""
							v-model="data.main_business"
							placeholder="请输入主营业务"
							placeholder-class="fff"
						/>
					</view>
				</view>
				<view class="h120"></view>
			</scroll-view>
			<button class="cu-btn btn flex align-center justify-center" @click.stop="dataModification">
				<text>修改</text>
			</button>
		</view>
		<!-- <u-tabbar v-model="current" :list="tabbarList" :border-top="false" active-color="#F2736D" @change="change"></u-tabbar> -->
		<yy-login v-if="vuex_login"></yy-login>
		<yy-loading text="加载中.." mask="true" click="true" ref="loading"></yy-loading>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
export default {
	data() {
		return {
			c: 1,
			data: {
				phone: '',
				company_name: '',
				industry_type: '',
				job_name: '',
				product_description: '',
				main_business: '',
				real_name: '',
				sex: 1 //1 男，2 女
			}
		};
	},
	onShow() {},

	onLoad(e) {
		this.getInfo();
	},
	methods: {
		async getInfo() {
			const res = await this.$u.post('/UserInfo/extendsInfo', {}, {});
			console.log('res >>  ', res);
			this.data = res.data;
			this.c = res.data.sex
		},
		async gender(e) {
			this.c = e;
			this.data.sex = e;
		},

		//资料修改
		async dataModification() {
			console.log('this.sex :>> ', this.sex);
			if (
				[
					this.data.phone,
					this.data.company_name,
					this.data.industry_type,
					this.data.job_name,
					this.data.product_description,
					this.data.main_business,
					this.data.real_name,
					this.data.sex
				].includes('')
			) {
				return this.$refs.uToast.show({ title: '请填写完整后提交', type: 'error' });
			}
			let obj = {
				phone: this.data.phone,
				company_name: this.data.company_name,
				industry_type: this.data.industry_type,
				job_name: this.data.job_name,
				product_description: this.data.product_description,
				main_business: this.data.main_business,
				real_name: this.data.real_name,
				sex: this.data.sex
			};
			const res = await this.$u.post('UserInfo/userExtends', obj, {});
			if (res.code) {
				this.$refs.uToast.show({ title: '修改成功', type: 'success' });
			}
			console.log('res >>  ', res);
		}
	}
};
</script>

<style lang="scss" scoped>
.page_box {
	/deep/input,
	.ddd {
		color: #333333;
		font-family: PingFang SC;
	}
	.text {
		display: flex;
	}
	.fff {
		color: #333333;
		font-family: PingFang SC;
	}
	.text::after {
		content: '*';
		color: #f2736d;
		margin-left: 5rpx;
	}
	.btn {
		position: fixed;
		bottom: calc(env(safe-area-inset-bottom) / 2);
		left: 50%;
		transform: translateX(-50%);
		width: 690rpx;
		height: 100rpx;
		background: #f2736d;
		border-radius: 50rpx;

		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #ffffff;
	}
}
</style>
